package com.kikoulol.jarmoryextractor;

import java.io.File;
import java.io.IOException;

import javax.naming.spi.DirectoryManager;
import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

public class Armory {
	
	public static final String EUROPE = "http://eu.wowarmory.com/";
	public static final String USA = "http://www.wowarmory.com/";
	public static final String KOREA = "http://kr.wowarmory.com/";
	public static final String CHINA = "http://cn.wowarmory.com/";
	public static final String TAIWAN = "http://tw.wowarmory.com/";
	
	public static String cacheFolder = "cache";
	
	private String armoryUrl;
	private String battleGroupName; 
	
	public static Character getCharacter(String armoryUrl) throws IOException, ParserConfigurationException, SAXException {
		return new Character(armoryUrl);
	}
	
	public static ArenaTeam getTeam(String armoryUrl) throws IOException, ParserConfigurationException, SAXException {
		return new ArenaTeam(armoryUrl);
	}
	
	public static void cleanCache() {
		File cache = new File(cacheFolder);
		for (File file : cache.listFiles()) {
			file.delete();
		}
		cache.delete();
	}
	
	public Armory(String region, String battleGroupName) {
		this.armoryUrl = region;
		this.battleGroupName = battleGroupName;
	}
	
	public Ladder get2v2Ladder() throws Exception {
		return new Ladder(Ladder.TWO,armoryUrl,battleGroupName);
	}
	
	public Ladder get3v3Ladder() throws Exception {
		return new Ladder(Ladder.THREE,armoryUrl,battleGroupName);
	}
	
	public Ladder get5v5Ladder() throws Exception {
		return new Ladder(Ladder.FIVE,armoryUrl,battleGroupName);
	}
	
	public Ladder getLadder(String type) throws Exception {
		return new Ladder(type,armoryUrl,battleGroupName);
	}

	public String getArmoryUrl() {
		return armoryUrl;
	}

	public void setArmoryUrl(String armoryUrl) {
		this.armoryUrl = armoryUrl;
	}

	public String getBattleGroupName() {
		return battleGroupName;
	}

	public void setBattleGroupName(String battleGroupName) {
		this.battleGroupName = battleGroupName;
	}

}
